#ifndef _IOTCPBASE_H_
#define _IOTCPBASE_H_

#include "iothreadpool.h"


uvNameSpaceBegin

#define IO_TCP_CONNECTED	1
#define IO_TCP_CONNECTFAIL	-1

struct io_tcp_i {
	os_sock_t			sock;
	io_data				io;
	io_event_loop*		eventloop;
	struct event*		ev;
	void(*tcp_fun_cb)(io_tcp_i *pData, int iStatus);
};

int	io_tcp_init(io_tcp_i* pTcp);
int	io_tcp_uninit(io_tcp_i* pTcp);
int	io_tcp_open(io_tcp_i *pTcp, os_sock_t sock);
int	io_tcp_listen(io_tcp_i *pTcp);
int	io_tcp_connect(io_tcp_i *pTcp, void* data, const char* ipaddress, unsigned long iport, int itimeout);
int	io_tcp_connect6(io_tcp_i *pTcp, void* data, const char* ipaddress, int iport);
int	io_tcp_bind(io_tcp_i *pTcp, const char* ipaddress, int iport);
int	io_tcp_bind6(io_tcp_i *pTcp, const char* ipaddress, int iport);

uvNameSpaceEnd

#endif 
